package com.iot.ammeter.controller.android.balance;

import com.iot.ammeter.anno.LogAnnotation;
import com.iot.ammeter.dto.app.balance.BalanceUserInfoDTO;
import com.iot.ammeter.responseResult.ResponseResult;
import com.iot.ammeter.service.android.balance.BalanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 余额查询控制类
 *
 * @author Yjx
 * @version 1.0.0
 * @since 2022/1/5
 **/
@RestController
@Api(tags = {"app端余额管理"})
@RequestMapping("/api/app_balance")
public class BalanceInfoController {

    private final BalanceService balanceService;

    public BalanceInfoController(BalanceService balanceService) {
        this.balanceService = balanceService;
    }

    /**
     * app端查询用户充值信息
     *
     * @param email 用户注册传输对象
     * @return
     */
    @ApiOperation("app端查询用户充值信息")
    @LogAnnotation(module = "appBalanceUserInfo", operator = "app端查询用户充值信息")
    @PostMapping("/info/{email}")
    public ResponseResult webUserRegister(@PathVariable String email) {
        Map<String, List<BalanceUserInfoDTO>> data = balanceService.selectBalanceInfo(email);
        return data.get("userBalanceInfo") != null ? ResponseResult.SUCCESS(data) : ResponseResult.FAILED("查询失败");
    }

}
